package ru.megazlo.basemvc.dao.dto;

import org.springframework.data.jpa.domain.AbstractPersistable;

import javax.persistence.*;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

@Entity
@Table(name = "Users")
public class User extends AbstractPersistable<Long> {

	@Column
	protected boolean enabled;
	@Column(length = 50, unique = true, nullable = false)
	protected String login;
	@Column(length = 50, nullable = false)
	protected String password;
	@Column
	protected String email;
	@Column
	protected String displayName;
	@ManyToMany
	protected Set<Role> roles = new HashSet<>();
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "owner")
	private List<Comment> comments;
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "autor")
	private List<News> news;

	public boolean isEnabled() {
		return enabled;
	}

	public void setEnabled(boolean enabled) {
		this.enabled = enabled;
	}

	public String getLogin() {
		return login;
	}

	public void setLogin(String login) {
		this.login = login;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getDisplayName() {
		return displayName;
	}

	public void setDisplayName(String displayName) {
		this.displayName = displayName;
	}

	public Set<Role> getRoles() {
		return roles;
	}

	public void setRoles(Set<Role> roles) {
		this.roles = roles;
	}

}
